bike_data$tooltip_text <-paste("Season:", bike_data$season,"<br>Total Rentals:", bike_data$cnt)p_bar <-ggplot(bike_data, aes(x =factor(season), y = cnt, fill =factor(season), text = tooltip_text)) +geom_bar(stat ="identity") +labs(title ="Total Bike Rentals Across Seasons", x ="Season", y ="Total Rentals") +theme_minimal()ggplotly(p_bar, tooltip ="text")
Code
bike_long <- bike_data %>%select(dteday, casual, registered, yr) %>%pivot_longer(cols =c(casual, registered), names_to ="user_type", values_to ="count")p <-ggplot(bike_long, aes(x = dteday, y = count, color = user_type, frame = yr, text =paste("Date: ", dteday, "<br>User Type: ", user_type, "<br>Count: ", count))) +geom_point(size =1) +scale_color_manual(values =c("registered"="blue", "casual"="red")) +labs(title ="Casual vs Registered Users Over Time", x ="Date", y ="Count") +theme_minimal()# Make it interactive and animatedggplotly(p, tooltip ="text") %>%animation_opts(frame =1000, easing ="linear")
Code
p_facet <-ggplot(bike_data, aes(x = dteday, y = cnt, color =factor(season))) +geom_line() +facet_wrap(~ season, scales ="free_y") +labs(title ="Bike Rentals Trends by Season", x ="Date", y ="Total Rentals") +theme_minimal() +theme(axis.text.x =element_text(angle =45, hjust =1))ggplotly(p_facet)